package huaweiExam;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str1 = sc.nextLine();
        String str2 = sc.nextLine();
        int vc = Integer.parseInt(sc.nextLine());

        System.out.println(getRes(str1, str2, vc));

    }

    public static int getRes(String str1, String str2, int limit) {
        if (str1 == null || str1 == "") {
            return 0;
        }
        int[] sums = new int[str1.length()];
        int start = -1;
        int res = 0;
        int len = 0;
        for (int i = 0; i < str1.length(); i++) {
            sums[i] = Math.abs(str1.charAt(i) - str2.charAt(i));
            if (sums[i] > limit) {
                if (start > -1) {
                    len = Math.max(len, i - start);
                }
                start = -1;
                res = 0;
                continue;
            } else if (start == -1) {
                start = i;
                res += sums[i];
            } else {
                res += sums[i];
            }
            if (res > limit) {
                len = Math.max(len, i - start);
                res -= sums[start++];
            } else if (i == str1.length() - 1) {
                len = Math.max(len, i + 1 - start);
            }
        }
        return len;

    }
}
